<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>大河网订阅管理系统</title>
    
    <link rel="stylesheet"  href="css/style.css" type="text/css" media="all" />
	<script src="js/My97DatePicker/WdatePicker.js"
			type="text/javascript"></script>
	<script src="js/jQuery-3.7.1.js"></script>
	<style>
	</style>

  </head>
  
  <body class="ContentBody"> 
		<form action="news" id="form-add" method="post">
			<div class="MainDiv">
				<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
					<tr>
						<th class="tablestyle_title" >文章添加</th>
					</tr>
					<tr>
						<td class="CPanel">
							<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
								<tr>
									<td width="100%">
										<fieldset style="height:100%;"><legend>添加文章</legend>
											<table border="0" cellpadding="2" cellspacing="1" style="width:100%" id="mytab">
												<tr>
													<td nowrap align="right">日期:	</td>
													<td><input name="newsDate" id="newsDate" style="width:154px" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
													<font color="red"> *</font></td>
													<td align="right" width="19%">报纸名称:</td>
													<td width="27%"><input name="newsName" id="newsName" class="text" style="width:154px" />
													<font color="red"> *</font></td>
												</tr>
												 <tr>
													<td nowrap align="right">版名:</td>
													<td><input name="layoutName" id="layoutName" class="text" style="width:154px" />
													<font color="red"> *</font></td>
													<td nowrap align="right">文章作者:</td>
													<td><input name="newsAuthor" id="newsAuthor" class="text" style="width:154px" /></td>
												</tr>
												<tr>
													<td nowrap align="right">文章标题:</td>
													<td colspan="3"><input name="newsTitle" id="newsTitle" class="text" style="width:354px" /></td>
												</tr>
												<tr>
													<td nowrap align="right">文章简介:</td>
													<td colspan="3">
													<textarea id="newsInfo" style="width:600px;height:50px" name="newsInfo"></textarea>
													</td>
												</tr>
												<tr>
													<td nowrap align="right">内容:</td>
													<td colspan="3">
														<textarea id="newsContent" style="width:600px;height:400px;" name="newsContent"></textarea>
													</td>
												</tr>
											</table>
										</fieldset>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center" height="50px">
							<input type="button" name="Submit" value="保存" class="button" id="btn-save"/>
							<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/>
						</td>
					</tr>
				</table>
			</div>
	    </form>
		<script>
			// 保存按钮添加点击事件
			$("#btn-save").click(function () {
				// 1.获取表单请求参数
				// 注意: serialize()只能通过表单对象获取
				let sendData = $("#form-add").serialize();
				// 2.发送请求
				$.getJSON("news/add",sendData,function (result) {
					// 判断返回结果
					if (result.code == 200){
						alert("添加成功!")
						// 跳转main.html查看添加的数据
						window.location.href = "main.html"
					}else {
						alert("添加失败!")
					}
				})

			})
		</script>
  </body>
</html>